from random import random,randint
from math import sqrt

def dist(a,b):
	return sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)

def sumx(C):
	return reduce(lambda x,y:x+y,C,0)

def mind(C):
	if len(C)==2: return dist(C[0],C[1])
	elif len(C)<2: return float("Inf")
	C.sort(key=lambda x:x[0])
	r=C[len(C)/2][0]
	d1=mind(C[:len(C)/2])
	d2=mind(C[len(C)/2:])
	d=min(d1,d2)
	C2=[x for x in C if r-d<=x[0]<=r+d]
	if len(C2)<2: return d
	else: return min([dist(a,b) for a in C2 for b in C2 if a!=b])

C=list(set([(randint(0,10),randint(0,10)) for x in range(5)]))
print C
print mind(C)
